package main

import (
	"flag"
	"fmt"
	"log"

	"code.google.com/p/microtool/command"
)

var (
	dialectFlag = flag.String("dialect", "gwbasic", "Dialect of BASIC to use when interpreting input.")
	inputFlag   = flag.String("input", "", "Path to input file.")
	commandFlag = flag.String("command", "list", "The basic command to execute.")
)

func main() {
	flag.Parse()
	cmd, ok := command.Active[*commandFlag]
	if !ok {
		log.Fatalf("Unknown command %q.  (Try --command=list)", *commandFlag)
	}

	if err := cmd.Fn(*inputFlag, *dialectFlag); err != nil {
		fmt.Printf("Oops, %s failed on %q: %v", cmd.Name, *inputFlag, err)
		log.Fatalf("%v", err)
	}
}
